from typing import Optional

from sqlalchemy import DateTime, String, text
from sqlalchemy.dialects.mysql import INTEGER, TINYINT
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
import datetime

class Base(DeclarativeBase):
    pass


class ProductManagement(Base):
    __tablename__ = 'product_management'
    __table_args__ = {'comment': '产品信息表'}

    id: Mapped[int] = mapped_column(INTEGER(10), primary_key=True, comment='产品ID')
    product_name: Mapped[str] = mapped_column(String(100), comment='产品名称')
    create_time: Mapped[datetime.datetime] = mapped_column(DateTime, server_default=text('CURRENT_TIMESTAMP'), comment='创建时间')
    add_time: Mapped[datetime.datetime] = mapped_column(DateTime, server_default=text('CURRENT_TIMESTAMP'), comment='添加时间')
    product_type: Mapped[Optional[str]] = mapped_column(String(100), comment='产品类型')
    image: Mapped[Optional[str]] = mapped_column(String(255), comment='产品图片URL')
    status: Mapped[Optional[int]] = mapped_column(TINYINT(4), comment='发布状态')
